<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-yellow sidebar-mini">

<section class="content">
    <div class="row">
        <div class="col-lg-4 col-xs-6">
            <div class="small-box bg-yellow">
                <div class="inner">
                    <div class="row" style="width: 100%;">
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">生产令待下达数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${oneRowOneCol1}"></label></h4>
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px; padding-top: 18px">设备类待排产数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;padding-top: 18px"
                                th:text="${oneRowOneCol2}"></label></h4>
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;padding-top: 18px">其他类待排产数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;padding-top: 18px"
                                th:text="${oneRowOneCol3}"></label></h4>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-xs-6">
            <div class="small-box bg-green">
                <div class="inner">
                    <div class="row" style="width: 100%;">
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">外购件待分配数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${oneRowTwoCol1}"></label></h4>
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">制作件清单待分配数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${oneRowTwoCol2}">0</label></h4>
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">工艺卡待接收数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${oneRowTwoCol3}">0</label></h4>
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">待下料任务数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${oneRowTwoCol4}">0</label></h4>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-xs-6">
            <div class="small-box bg-purple">
                <div class="inner">
                    <div class="row" style="width: 100%;">
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px">装配派工单下达数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${oneRowThreeCol1}">0</label></h4>
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;padding-top: 18px">发货清单审核数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;padding-top: 18px"
                                th:text="${oneRowThreeCol2}">0</label></h4>
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;padding-top: 18px">安装派工单下达数量：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;padding-top: 18px"
                                th:text="${oneRowThreeCol3}">0</label></h4>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-4 col-xs-6">
            <div class="small-box bg-light-blue">
                <div class="inner">
                    <div class="row" style="width: 100%;">
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">生产任务池零件数：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${twoRowOneCol}"></label></h4>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-xs-6">
            <div class="small-box bg-orange">
                <div class="inner">
                    <div class="row" style="width: 100%;">
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">半成品库池零件数：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${twoRowTwoCol}"></label></h4>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-4 col-xs-6">
            <div class="small-box bg-green">
                <div class="inner">
                    <div class="row" style="width: 100%;">
                        <h4 style="width: 100%;line-height: 30px;"><label class="col-md-9" style="padding-left: 45px;">成品库池零件数：</label><label
                                class="col-md-3" style="text-align: right;padding-right: 45px;"
                                th:text="${twoRowThreeCol}"></label></h4>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-3">
            <div class="box box-success">
                <div class="box-header with-border text-center">
                    <h3 class="box-title">待下料任务量</h3>
                </div>
                <div class="box-body no-padding" style="height: 120px;">
                    <ul style="padding: 15px;width: 100%;list-style: none">
                        <a th:href="@{/overview/cutMaintain}">
                            <li><label class="col-md-9">待执行项目数:</label><label class="col-md-3"
                                                                              th:text="${threeRowOneCol1}">0</label>
                            </li>
                        </a>
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="box box-success">
                <div class="box-header with-border text-center">
                    <h3 class="box-title">铆焊厂任务量</h3>
                </div>
                <div class="box-body no-padding" style="height: 120px;">
                    <ul style="padding: 15px;width: 100%;list-style: none">
                        <a th:href="@{/overview/solderQuery}">
                            <li><label class="col-md-9">待执行项目数:</label><label class="col-md-3"
                                                                              th:text="${threeRowTwoCol1}">0</label>
                            </li>
                        </a>
                        <a th:href="@{/overview/coatQuery}">
                            <li><label class="col-md-9">涂装任务量:</label><label class="col-md-3"
                                                                             th:text="${threeRowTwoCol2}">0</label></li>
                        </a>
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="box box-success">
                <div class="box-header with-border text-center">
                    <h3 class="box-title">机加厂任务量</h3>
                </div>
                <div class="box-body no-padding" style="height: 120px;">
                    <ul style="padding: 15px;width: 100%;list-style: none">
                        <a th:href="@{/overview/machiningQuery}">
                            <li><label class="col-md-9">待执行项目数:</label><label class="col-md-3"
                                                                              th:text="${threeRowThreeCol1}">0</label>
                            </li>
                        </a>
                        <a th:href="@{/overview/macTaskPage/机械}">
                            <li><label class="col-md-9">机械装配任务量:</label><label class="col-md-3"
                                                                               th:text="${threeRowThreeCol2}">0</label>
                            </li>
                        </a>
                        <a th:href="@{/overview/macTaskPage/流体}">
                            <li><label class="col-md-9">流体装配任务量:</label><label class="col-md-3"
                                                                               th:text="${threeRowThreeCol3}">0</label>
                            </li>
                        </a>
                    </ul>
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <div class="box box-success">
                <div class="box-header with-border text-center">
                    <h3 class="box-title">电装分厂任务量</h3>
                </div>
                <div class="box-body no-padding" style="height: 120px;">
                    <ul style="padding: 15px;width: 100%;list-style: none">
                        <a th:href="@{/overview/bakcPage}">
                            <li><label class="col-md-9">待执行项目数:</label><label class="col-md-3"
                                                                              th:text="${threeRowFourCol1}">0</label>
                            </li>
                        </a>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <div class="box box-success">
                <div class="box-header with-border text-center">
                    <button onclick="purWeldMonthPre()" style="border:none;background-color: transparent;outline: none;"
                            class="text-primary">
                        <i class="fa fa-fw fa-arrow-left"></i>
                        前一月
                    </button>
                    <h3 class="box-title" id="lbl_purWeldMonth">铆焊厂产能统计</h3>
                    <button onclick="purWeldMonthNext()"
                            style="border:none;background-color: transparent;outline: none;"
                            class="text-primary">
                        后一月
                        <i class="fa fa-fw fa-arrow-right text-primary"></i>
                    </button>
                </div>
                <div class="box-body no-padding" style="height: 120px;">
                    <ul style="padding: 15px;width: 100%;list-style: none">
                        <li><label class="col-md-9">当月计划量（吨）:</label><label class="col-md-3" id="fourRowOneCol1">3252</label>
                        </li>
                        <li><label class="col-md-9">当月完成量（吨）:</label><label class="col-md-3" id="fourRowOneCol2">2648</label>
                        </li>
                        <li><label class="col-md-9">计划完成率（按重量统计）:</label><label class="col-md-3" id="fourRowOneCol3">81.40%</label>
                        </li>
                        <li><label class="col-md-9">排产完成率（按项目统计）:</label><label class="col-md-3" id="fourRowOneCol4">72%</label>
                        </li>
                    </ul>
                </div>
                <div class="box-footer text-right">
                    <a id="hrefWeld" th:href="@{/overview/weldStatsQuery}" class="uppercase">查看详细</a>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="box box-success">
                <div class="box-header with-border text-center">
                    <button onclick="purCutMonthPre()" style="border:none;background-color: transparent;outline: none;"
                            class="text-primary">
                        <i class="fa fa-fw fa-arrow-left"></i>
                        前一月
                    </button>
                    <h3 class="box-title" id="lbl_purCutMonth">机加厂产能统计</h3>
                    <button onclick="purCutMonthNext()"
                            style="border:none;background-color: transparent;outline: none;"
                            class="text-primary">
                        后一月
                        <i class="fa fa-fw fa-arrow-right text-primary"></i>
                    </button>
                </div>
                <div class="box-body no-padding" style="height: 120px;">
                    <ul style="padding: 15px;width: 100%;list-style: none">
                        <li><label class="col-md-9">当月计划量（小时）:</label><label class="col-md-3" id="fourRowTwoCol1">3400</label>
                        </li>
                        <li><label class="col-md-9">当月完成量（小时）:</label><label class="col-md-3" id="fourRowTwoCol2">3230</label>
                        </li>
                        <li><label class="col-md-9">计划完成率（按小时统计）:</label><label class="col-md-3" id="fourRowTwoCol3">95%</label>
                        </li>
                        <li><label class="col-md-9">排产完成率（按项目统计）:</label><label class="col-md-3" id="fourRowTwoCol4">79.6%</label>
                        </li>
                    </ul>
                </div>
                <div class="box-footer text-right">
                    <a id="hrefCut" th:href="@{/overview/cutStatsQuery}" class="uppercase">查看详细</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header text-center">
                    <h3 class="box-title">生产令月进度统计</h3>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
                <!-- /.box-body -->
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;
    /**月份数组*/
    var month = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"];
    /**铆焊厂产能统计全局当前月份*/
    var purCurrentMonthAll;
    var currentYearPur;
    /**机加厂产能统计全局当前月份*/
    var purCutCurrentMonthAll;
    var currentCutYearPur;


    /** 铆焊厂产能统计 **/
    function purMonthControl() {
        purCurrentMonthAll = new Date().getMonth();
        $("#lbl_purWeldMonth").html("铆焊厂产能统计" + yearConvert(currentYearPur) + "年" + month[purCurrentMonthAll] + '数据');
        loadPurDataByMont(purCurrentMonthAll);
    }
    /** 铆焊厂产能上一月按钮事件 **/
    function purWeldMonthPre() {
        if (purCurrentMonthAll != 0) {
            purCurrentMonthAll -= 1;
            $("#lbl_purWeldMonth").html("铆焊厂产能统计" + yearConvert(currentYearPur) + "年" + month[purCurrentMonthAll] + '数据');
            loadPurDataByMont(purCurrentMonthAll);
        } else {
            purCurrentMonthAll = 11;
            currentYearPur -= 1;
            $("#lbl_purWeldMonth").html("铆焊厂产能统计" + yearConvert(currentYearPur) + "年" + month[purCurrentMonthAll] + '数据');
            loadPurDataByMont(purCurrentMonthAll);
        }
    }
    /** 铆焊厂产能下一月按钮事件 **/
    function purWeldMonthNext() {
        if (purCurrentMonthAll == 11 && currentYearPur <= new Date().getFullYear()) {
            purCurrentMonthAll = 0;
            currentYearPur += 1;
            $("#lbl_purWeldMonth").html("铆焊厂产能统计" + yearConvert(currentYearPur) + "年" + month[purCurrentMonthAll] + '数据');
            loadPurDataByMont(purCurrentMonthAll);
        } else if ((purCurrentMonthAll < 11 && currentYearPur < new Date().getFullYear()) || (purCurrentMonthAll < new Date().getMonth() && currentYearPur == new Date().getFullYear())) {
            purCurrentMonthAll += 1;
            $("#lbl_purWeldMonth").html("铆焊厂产能统计" + yearConvert(currentYearPur) + "年" + month[purCurrentMonthAll] + '数据');
            loadPurDataByMont(purCurrentMonthAll);
        } else {
            js.modal.warning("未来数据不可查询！");
        }
    }
    /** 铆焊厂产能控件初始化 **/
    function loadPurDataByMont(month) {
        $.post(
            ctx + 'overview/loadWeldPurDataByDate',
            {
                year: currentYearPur,
                month: month
            },
            function (result) {
                if (result.type === web_status.SUCCESS) {
                    $("#fourRowOneCol1").html(result.data.oneYield);
                    $("#fourRowOneCol2").html(result.data.twoYield);
                    $("#fourRowOneCol3").html(result.data.threeYield + '%');
                    $("#fourRowOneCol4").html(result.data.fourYield + '%');
                    $("#hrefWeld").attr("href", "/overview/weldStatsQuery/" + currentYearPur + "/" + month);
                } else {
                    js.modal.warning(result.msg);
                }
            }, 'json'
        )
    }

    /** 机加厂产能统计 **/
    function purCutMonthControl() {
        purCutCurrentMonthAll = new Date().getMonth();
        $("#lbl_purCutMonth").html("机加厂产能统计" + yearConvert(currentCutYearPur) + "年" + month[purCutCurrentMonthAll] + '数据');
        loadCutPurDataByMont(purCutCurrentMonthAll);
    }
    /** 机加厂产能上一月按钮事件 **/
    function purCutMonthPre() {
        if (purCutCurrentMonthAll != 0) {
            purCutCurrentMonthAll -= 1;
            $("#lbl_purCutMonth").html("机加厂产能统计" + yearConvert(currentCutYearPur) + "年" + month[purCutCurrentMonthAll] + '数据');
            loadCutPurDataByMont(purCutCurrentMonthAll);
        } else {
            purCutCurrentMonthAll = 11;
            currentCutYearPur -= 1;
            $("#lbl_purCutMonth").html("机加厂产能统计" + yearConvert(currentCutYearPur) + "年" + month[purCutCurrentMonthAll] + '数据');
            loadCutPurDataByMont(purCutCurrentMonthAll);
        }
    }
    /** 机加厂产能下一月按钮事件 **/
    function purCutMonthNext() {
        if (purCutCurrentMonthAll == 11 && currentCutYearPur <= new Date().getFullYear()) {
            purCutCurrentMonthAll = 0;
            currentCutYearPur += 1;
            $("#lbl_purCutMonth").html("机加厂产能统计" + yearConvert(currentCutYearPur) + "年" + month[purCutCurrentMonthAll] + '数据');
            loadCutPurDataByMont(purCutCurrentMonthAll);
        } else if ((purCutCurrentMonthAll < 11 && currentCutYearPur < new Date().getFullYear()) || (purCutCurrentMonthAll < new Date().getMonth() && currentYearPur == new Date().getFullYear())) {
            purCutCurrentMonthAll += 1;
            $("#lbl_purCutMonth").html("机加厂产能统计" + yearConvert(currentCutYearPur) + "年" + month[purCutCurrentMonthAll] + '数据');
            loadCutPurDataByMont(purCutCurrentMonthAll);
        } else {
            js.modal.warning("未来数据不可查询！");
        }
    }
    /** 机加厂产能控件初始化 **/
    function loadCutPurDataByMont(month) {
        $.post(
            ctx + 'overview/loadCutPurDataByDate',
            {
                year: currentCutYearPur,
                month: month
            },
            function (result) {
                if (result.type === web_status.SUCCESS) {
                    $("#fourRowTwoCol1").html(result.data.oneYield);
                    $("#fourRowTwoCol2").html(result.data.twoYield);
                    $("#fourRowTwoCol3").html(result.data.threeYield + '%');
                    $("#fourRowTwoCol4").html(result.data.fourYield + '%');
                    $("#hrefCut").attr("href", "/overview/cutStatsQuery/" + currentCutYearPur + "/" + month);
                } else {
                    js.modal.warning(result.msg);
                }
            }, 'json'
        )
    }


    $(function () {
        currentYearPur = new Date().getFullYear();
        currentCutYearPur = new Date().getFullYear();

        purMonthControl();
        purCutMonthControl();

        /** 加载列表 */
        table = js.table.init({
            url: ctx + "overview/prodArrange",
            showExport: false,
            pagination: false,
            columns: [
                {title: "项目年份", field: 'year'},
                {title: "下生产令数", field: 'issueNum'},
                {title: "取消数", field: 'cancelNum'},
                {title: "暂缓数", field: 'deferNum'},
                {title: "设备类完成数", field: 'equCompNum'},
                {title: "其他类完成数", field: 'otherCompNum'},
                {title: "未完成数", field: 'inCompNum'},
                {title: "当月完成数", field: 'curCompNum'},
                {
                    title: "总完成率", field: 'compRate',
                    formatter: function (value, row, index) {
                        return value + "%";
                    }
                }
            ]
        });


    });

    /**
     * 小写转换成大写
     * @param year
     * @returns {string}
     */
    function yearConvert(year) {
        let yearStr = year.toString();
        let arr = yearStr.split("");
        let capitalFiguresArr = ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
        let resultStr = "";
        for (let i = 0; i < arr.length; i++) {
            resultStr += capitalFiguresArr[parseInt(arr[i])];
        }
        return resultStr;
    }

</script>
</body>
</html>